import fetch from '../utils/network/fetch'

// 登陆
const login = objc => {
    fetch('/login', objc)
}

// 读取分类树
const getClassifications = (type, objc) => {
    fetch(`/api/classification?class_type=${type}&&build_tree=true`, objc)
}

// 保存分类
const saveClassification = (data, objc) => {
    data &&
        fetch('/api/classification', {
            ...objc,
            method: 'put',
            data
        })
}

// 删除分类
const removeClassification = (id, objc) => {
    id &&
        fetch(`/api/classification/${id}`, {
            ...objc,
            method: 'delete'
        })
}

export default {
    login,
    getClassifications,
    saveClassification,
    removeClassification
}
